package com.example.study.service.impl;

import com.example.study.mapper.UserMapper;
import com.example.study.pojo.User;
import com.example.study.service.IUserService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author 宋伟宁
 * @Date 2023/10/8
 * @Version 1.0
 **/
@Service
public class UserService  implements IUserService {
    @Resource
    private UserMapper userMapper ;
    @Override
    public List<User> findAll() {
        return this.userMapper.findAll();
    }

    @Override
    public boolean del(int uid) {
        return this.userMapper.del(uid)==1;
    }

    @Override
    public boolean save(User user) {
        if(user.getUid()==null) return  this.userMapper.add(user)==1;

        return this.userMapper.update(user)==1;
    }

    @Override
    public User findById(int uid) {
        return this.userMapper.findById(uid);
    }
}
